package bean;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import javax.annotation.PostConstruct;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.SessionScoped;

import model.Experience;

import org.springframework.beans.factory.annotation.Autowired;

import service.ExperienceService;
@ManagedBean(name="experienceBean")
@SessionScoped
public class ExperienceBean implements Serializable{

	/**
	 * 
	 */
	private static final long serialVersionUID = 7039924453814829865L;
	private Experience exp;
	private ArrayList<Experience> expList;
	
	@Autowired
	private ExperienceService experienceService;
	
	
	@ManagedProperty(value = "#{experienceService}")
	private Experience tempExperience;
	private List<Experience> popExper;
	
	@PostConstruct
	public void init(){
		tempExperience = new Experience();
		expList = showExperience();
	}
	
	
	public void saveExperience(){
		System.out.println("asda");
	     experienceService.saveExperience(exp);
	}
	
	public ArrayList<Experience> showExperience(){
		ArrayList<Experience> eee = (ArrayList<Experience>) experienceService.generatePopExperiences();
		System.out.println(eee.get(0).text);
		return eee;
	}
	
	public Experience getExp() {
		return exp;
	}

	public void setExp(Experience exp) {
		this.exp = exp;
	}

	public ExperienceService getExperienceService() {
		return experienceService;
	}

	public void setExperienceService(ExperienceService experienceService) {
		this.experienceService = experienceService;
	}

	public List<Experience> getPopExper() {
		return popExper;
	}

	public void setPopExper(List<Experience> popExper) {
		this.popExper = popExper;
	}
	
	public ArrayList<Experience> getExpList() {
		return expList;
	}

	public void setExpList(ArrayList<Experience> expList) {
		this.expList = expList;
	}

}
